Supported with v3.0.0+

The Ratings Controller (attached to the Gameboard prefab game object) exposes all the ratings features available to creators. This allows creators to expose means for user's to rate their game on the board, and also retrieve the average rating for their game based on overall user ratings.

To access the Rating Controller, you need the Gameboard prefab. The Gameboard prefab is always available in your game as long as the SDK has been integrated. In order to access it from our custom Mono Behavior we just need to find it by its tag.

    GameObject gameboardObject = GameObject.FindWithTag("Gameboard");

Once you have the Gameboard prefab, you can now access the Rating Controller.

We will first need to define a reference to the controller to make it available throughout our script:

     TouchController touchController;

And we can assign the controller in the Start method:

    ratingController = gameboardObject.GetComponent<RatingController>();

From the ratingController, you can now access the following methods:

This section include the entire code in one single, easy to copy section.

    ratingsController ratingsController;

    void Start()
    {
        GameObject gameboardObject = GameObject.FindWithTag("Gameboard");
        ratingsController = gameboardObject.GetComponent<ratingsController>();
    }

    void SetRating(string userId)
    {
        // User logged into the board is giving the game a 10 rating
        ratingController.RateGame(10);

        // User with the specified userId is giving the game a 5.5 rating
        ratingController.RateGameForUser(5.5, userId);
    }

    void GetRating(string userId)
    {
        var ratingForBoardUser = ratingController.GetGameRating();
        var ratingForSpecifiedUser = ratingController.GetGameRatingForUser(userId);
    }

    void GetOverallRating()
    {
        var overallRating = ratingController.GetGameAverageRating(); //Returns the current rating average of the game based on all user ratings
    }